<!-- 登录拦截 -->
<script src="../assets/utils/jquery/jquery.min.js"></script>
<script>
    $.ajax({
        type: 'get',
        url: '/login/status',
        success: res => {
            console.log(res);
            if (res.userId) {
                sessionStorage.setItem('userId', res.userId)
            } else {
                location.href = 'login.html'
            }
        }
    })
</script>
<!-- 登录拦截结束 -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台管理-首页</title>
    <link rel="stylesheet" href="../assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="../assets/css/admin/common.css">
    <link rel="stylesheet" href="../assets/css/admin/index.css">
    <link rel="stylesheet" href="../assets/utils/nprogress/nprogress.css">
    <script src="../assets/utils/nprogress/nprogress.js"></script>
</head>

<body>
    <script>
        NProgress.start()
    </script>
    <!-- 1、左边导航栏区域 -->
    <div class="aside">
        <!-- 1-1-用户头像信息 -->
        <div class="user-info" id="userData">
            <img src="/assets/uploads/5.jpg" alt="">
            <h3>梦里百川</h3>
        </div>
        <!-- 1-2-菜单栏信息 -->
        <ul class="nav">
            <li class="active">
                <a href="index.html"><span class="glyphicon glyphicon-equalizer"></span>首页</a>
            </li>

            <li>
                <a href="#menu-posts" class="collapsed" data-toggle="collapse">
                    <span class="glyphicon glyphicon-level-up"></span>文章<i class="glyphicon glyphicon-menu-down"></i>
                </a>
                <ul id="menu-posts" class="collapse">
                    <li><a href="allArticle.html">所有文章</a></li>
                    <li><a href="writeArticle.html">写文章</a></li>
                    <li><a href="catalogArticle.html">文章类别</a></li>
                </ul>
            </li>

            <li>
                <a href="comments.html"><span class="glyphicon glyphicon-equalizer"></span>评论</a>
            </li>
            <li>
                <a href="users.html"><span class="glyphicon glyphicon-equalizer"></span>用户</a>
            </li>
            <li>
                <a href="#menu-settings" class="collapsed" data-toggle="collapse">
                    <span class="glyphicon glyphicon-equalizer"></span>设置<i class="glyphicon glyphicon-menu-down"></i>
                </a>
                <ul id="menu-settings" class="collapse">
                    <li><a href="rotation.html">图片轮播</a></li>
                    <li><a href="settings.html">网站设置</a></li>
                </ul>
            </li>
        </ul>
    </div>
    <div class="seat"></div>
    <!-- 2、主体内容区域 -->
    <div class="main">
        <!-- 2-1-顶部小白条 -->
        <div class="navbar">
            <h3>首页</h3>
            <ul>
                <li><a href="resetPwd.html"><i class="glyphicon glyphicon-wrench"></i> 修改密码</a></li>
                <li><a href="javascript:;" id="logout"><i class="glyphicon glyphicon-off"></i> 退出登录</a></li>
            </ul>
        </div>
        <!-- 2-2-主体内容 -->
        <div class="container-box">
            <!-- 2-2-1-巨幕 -->
            <div class="jumbotron text-center">
                <h1>欢迎来到十六博客管理系统</h1>
                <p>多听多写，好过什么都不做</p>
                <p><a class="btn btn-primary btn-lg" href="writeArticle.html" role="button">去写博客</a></p>
            </div>
            <!-- 2-2-2-文章列表统计 -->
            <div class="row">
                <div class="artic-total col-md-6">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">站点内容统计：</h3>
                        </div>
                        <ul class="list-group">
                            <li class="list-group-item" id="totalNum">
                                <strong>0</strong>篇文章（<strong>0</strong>篇草稿）
                            </li>
                            <li class="list-group-item" id="totalType">
                                <strong>0</strong>个分类
                            </li>
                            <li class="list-group-item" id="totalCom">
                                <strong>5</strong>条评论（<strong>1</strong>条待审核）
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="col-md-6"></div>
            </div>

        </div>

    </div>



    <!-- js -->
    <script src="../assets/js/bootstrap.min.js"></script>
    <script src="../assets/js/common.js"></script>
    <script>
        NProgress.done()
    </script>
    <script>
        // 1、统计文章数据
        $.ajax({
            type: 'get',
            url: '/posts/count',
            success: res => {
                // console.log(res);
                var template =
                    `
                <strong>${res.postCount}</strong>篇文章（<strong>${res.draftCount}</strong>篇草稿）
                `
                $('#totalNum').html(template)
            }
        })
        // 2、统计分类
        $.ajax({
            type: 'get',
            url: '/categories/count',
            success: res => {
                var template =
                    `
                <strong>${res.categoryCount}</strong>个分类
                `
                $('#totalType').html(template)
            }
        })
        // 3、统计评论
        $.ajax({
            type: 'get',
            url: '/comments/count',
            success: res => {
                var template =
                    `
                <strong>${res.commentCount}</strong>条评论
                `
                $('#totalCom').html(template)
            }
        })
    </script>
</body>

</html>